home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
.net (Turkey) 1998 March
/
.net Internet Dergisi - CD 5.iso
/
mac
/
CON_BM
/
00291_Script_ScrollBox
< prev
next >
Wrap
Text File
|
1997-11-07
|
3KB
|
113 lines
-- Parent script for Scroll Bars
property barSprite, boxSprite, clickHeight, topLimit, bottomLimit, scrollLength, curLine, controlField,fieldPixToBarPix,controlFieldLength
on new me,bar,box,hght
set curLine = 1
set barSprite = bar
set boxSprite = box
set clickHeight = hght
return me
end
on init me,theFld
-- store some variables based on the size of the field
--
set topLimit = (the top of sprite barSprite + clickHeight) + ((the height of sprite boxSprite)/2)
set bottomLimit = the bottom of sprite barSprite - clickHeight - ((the height of sprite boxSprite)/2)
set scrollLength = bottomLimit - topLimit
calibrate me,theFld
puppetSprite boxSprite,TRUE
-- set the loch of Sprite boxSprite = 300
-- set the locv of Sprite boxSprite = 300
-- updatestage
end
on calibrate me,theFld
-- calculate the ratio of the size of the field to the size of the scrollbar
--
set controlField = the number of member theFld
set controlFieldLength = getAt(charPosToLoc(member controlField, the number of chars in field controlField),2)
set fieldPixToBarPix = controlFieldLength/scrollLength
end
on clickBox me
-- move the scroll box and scroll the field with it
--
repeat while the stillDown
if the mouseV >= topLimit and the mouseV <= bottomLimit then
set the locV of sprite boxSprite = the mouseV
updatestage
end if
end repeat
set newloc = the locV of sprite boxSprite
if newLoc < topLimit + 10 then
boxToTop me
else
set the scrollTop of member controlField = integer((newLoc - topLimit) * fieldPixToBarPix)
end if
end
on clickEnd me
-- if user clicked at very top or bottom of scrollbar, scroll the field
--
set saveV = getAt(the clickLoc,2)
if saveV < the top of sprite barSprite + clickHeight then
set the membernum of sprite 28 to member "txt_butup"
updateStage
scrollUp me
else if saveV > the bottom of sprite barSprite - clickHeight then
set the membernum of sprite 28 to member "txt_butdown"
updateStage
scrollDown me
end if
end
on scrollDown me
-- scroll the field down, move box too
--
if fieldPixToBarPix < 1 then exit
repeat while the stillDown
if the locV of sprite boxSprite < bottomLimit then
scrollByLine member controlField, 1
moveBox me
end if
end repeat
end
on scrollUp me
-- scroll the field up, move box too
--
if fieldPixToBarPix < 1 then exit
repeat while the stillDown
scrollByLine member controlField, -1
moveBox me
end repeat
end
on moveBox me
-- move box in relation to scroll position of field
--
if fieldPixToBarPix < 1 then exit
set newPos = (the scrollTop of member "NameofFieldToControl")/fieldPixToBarPix
set newPos = topLimit + newPos
if newPos <= bottomLimit then
set the locV of sprite boxSprite = newPos
updateStage
end if
end
on boxToTop me
-- scroll field to top and move box to top of scrollbar
--
set the locV of sprite boxSprite = topLimit
updateStage
-- set the scrollTop of member controlField = 1
set the scrollTop of member "NameofFieldToControl" = 1
updatestage
moveBox me
updatestage
end